package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.SkuSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName SkuController
 * @Description
 * @Author 洛尘
 * @Date 19:26 2019/11/15
 * @Version 2.1
 **/
@RestController
@RequestMapping("/search")
public class SkuSearController {

    @Autowired(required = false)
    private SkuSearchService skuSearchService;


    /**
     * @author ShortDust
     * @Description  检索
     * @ClassName SkuSearController
     * @date 2019/11/15 21:08
     * @return
    */
    @GetMapping
    public Map<String, Object> search(@RequestParam(required = false) Map<String, String> searchMap) {
        Map<String,Object> resultMap = skuSearchService.search(searchMap);
        return resultMap;
    }


    /**
     * @return
     * @author ShortDust
     * @Description 数据库的数据导入到索引库中
     * @ClassName SkuSearController
     * @date 2019/11/15 21:03
     */
    @GetMapping("/import")
    public Result importDate() {
        skuSearchService.inportSkuInfoES();
        return new Result(true, StatusCode.OK, "数据导入成功");
    }

}
